Conversation
|
@asticode |
asticode
left a comment
There was a problem hiding this comment.
Sorry for reviewing so late.
Don't bother for the tests, I'll see what I can do later.
The PR needs some changes though.
|
@asticode |
astilectron.go
Outdated
| EventNameAppTooManyAccept = "app.too.many.accept" | ||
| ) | ||
|
|
||
| // // Unix socket path |
astilectron.go
Outdated
| ElectronSwitches []string | ||
| SingleInstance bool | ||
| SkipSetup bool // If true, the user must handle provisioning and executing astilectron. | ||
| TCPPort *int // The port to listen on. |
There was a problem hiding this comment.
Replace this attribute by Addr string so that users may provide their proper addr, not just port
astilectron.go
Outdated
| singleInstance = "false" | ||
| } | ||
| var cmd = exec.CommandContext(ctx, a.paths.AppExecutable(), append([]string{a.paths.AstilectronApplication(), a.listener.Addr().String(), singleInstance}, a.options.ElectronSwitches...)...) | ||
| var cmd = exec.CommandContext(ctx, a.paths.AppExecutable(), append([]string{a.paths.AstilectronApplication(), listenType, a.listener.Addr().String(), singleInstance}, a.options.ElectronSwitches...)...) |
There was a problem hiding this comment.
You shouldn't have to add a flag here. However make sure a.listener.Addr().String() contains the full addr (unix://path/to/socket or tcp://127.0.0.1:4003)
astilectron.go
Outdated
|
|
||
| // execute executes Astilectron in Electron | ||
| func (a *Astilectron) execute() (err error) { | ||
| func (a *Astilectron) execute(listenType string) (err error) { |
astilectron.go
Outdated
| // Execute | ||
| if !a.options.SkipSetup { | ||
| if err = a.execute(); err != nil { | ||
| if err = a.execute(listenType); err != nil { |
astilectron.go
Outdated
| return "", nil | ||
| } | ||
|
|
||
| func (a *Astilectron) listenFunc(fn func() error) (err error) { |
There was a problem hiding this comment.
Creating this intermediary function doesn't seem really useful
astilectron.go
Outdated
| // Creates a unix socket | ||
| func (a *Astilectron) listenUnix() (err error) { | ||
|
|
||
| UNIX_SOCKET_PATH := filepath.Join(a.paths.DataDirectory(), "astilectron.sock") |
There was a problem hiding this comment.
Don't name the variable in upper case with _. Name it p
astilectron.go
Outdated
|
|
||
| UNIX_SOCKET_PATH := filepath.Join(a.paths.DataDirectory(), "astilectron.sock") | ||
|
|
||
| _ = os.Remove(UNIX_SOCKET_PATH) |
astilectron.go
Outdated
|
|
||
| _ = os.Remove(UNIX_SOCKET_PATH) | ||
|
|
||
| if err := a.listenFunc(func() error { |
There was a problem hiding this comment.
No need for this listenFunc intermediary function
astilectron.go
Outdated
| // and listens to the first TCP connection coming its way (this should be Astilectron). | ||
| func (a *Astilectron) listenTCP() (err error) { | ||
| // function to create TCP/Unix socket connection | ||
| func (a *Astilectron) listen() (string, error) { |
There was a problem hiding this comment.
After seeing this, it seems overly complicated.
Here's what I'd rather do:
- Determine
var addr string=> checka.options.Addrfirst, then checkos - Depending on the
schemeofaddr, create the proper connection
|
Tried testing the changes using the astilectron bundler but did not succeed in that as the bundler always downloads the astilectron from the master tested go-astilectron part the "Addr" is getting updated properly. |
|
When using the bundler, you can use the |
afe15dc to
0302461
Compare
|
Made some changes in the client connection part, instead of checking the string for "tcp://" or "unix://" I have used net.isIP(). |
#190
Partnering pull request can be found here: asticode/astilectron#20